package pro.shushi.pamirs.hr.core.action.auth;

import com.google.common.collect.Lists;
import org.springframework.stereotype.Component;
import pro.shushi.pamirs.framework.connectors.data.sql.query.LambdaQueryWrapper;
import pro.shushi.pamirs.framework.connectors.data.sql.query.QueryWrapper;
import pro.shushi.pamirs.hr.api.pmodel.AuthResourceModule;
import pro.shushi.pamirs.meta.annotation.Function;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.annotation.fun.extern.Slf4j;
import pro.shushi.pamirs.meta.api.dto.condition.Pagination;
import pro.shushi.pamirs.meta.api.dto.wrapper.IWrapper;
import pro.shushi.pamirs.meta.constant.FunctionConstants;
import pro.shushi.pamirs.meta.enmu.FunctionOpenEnum;
import pro.shushi.pamirs.meta.enmu.FunctionTypeEnum;
import pro.shushi.pamirs.meta.enmu.SystemSourceEnum;

@Slf4j
@Model.model(AuthResourceModule.MODEL_MODEL)
@Component
public class AuthResourceModuleAction {

    @Function.Advanced(type= FunctionTypeEnum.QUERY)
    @Function.fun(FunctionConstants.queryPage)
    @Function(openLevel = {FunctionOpenEnum.API})
    public Pagination<AuthResourceModule> queryPage(Pagination<AuthResourceModule> page, IWrapper<AuthResourceModule> queryWrapper){
        LambdaQueryWrapper<AuthResourceModule> wrapper = ((QueryWrapper<AuthResourceModule>) queryWrapper).lambda();
        wrapper.notIn(AuthResourceModule::getModule, Lists.newArrayList("message", "sequence", "common", "user", "auth",
                "base", "apps", "designer_common", "ai_designer", "tp_map", "eip_designer", "workflow_designer", "business",
                "trigger", "data_designer", "tp_communication", "ui_designer", "model_designer", "eip", "datavi",
                "workflow_designer_base", "ui_designer_data_widget", "international", "ui_designer_biz_widget", "tp_message",
                "expression", "sql_record", "translate", "workflow", "file","sys_setting", "data_audit","resource","management_center","sso"))
                .notIn(AuthResourceModule::getSystemSource,Lists.newArrayList(SystemSourceEnum.BASE.value(), SystemSourceEnum.SYSTEM.value()));
        return new AuthResourceModule().queryPage(page, queryWrapper);
    }

}